<?php
/**
 * 文章详情管理
 */
defined('BY_JYA') or exit('error');
$pindex = max(1, intval($_RQ['page']));
$psize = 10;
$op=$_RQ['op']?$_RQ['op']:'notice';
$nickname=pdo_getcolumn('jy_jdpm_member',array('mid'=>$_SESSION['uid']),'nickname');
$return['nickname']=$nickname;
if(empty($_SESSION['channel'])){
		$_SESSION['channel'] = pdo_getall('jy_jdpm_goods_group',array('pid' => 0),'','','sort asc');
}
$return['channel'] = $_SESSION['channel'];
if($op=='help'){
	$id = intval($_RQ['id']);
     $list = pdo_getall('jy_jdpm_goods_group',array('pid' =>array(1,12)),'','','sort desc');
        if ($id) {
            $info = pdo_get('jy_jdpm_news',array('id' =>$id));
        }else{
			$info = pdo_get('jy_jdpm_news',array('cid' =>$list[0]['cid'],'status'=>1));
        }
        foreach ($list as $lk => $lv) {
            $list[$lk]['notice'] = pdo_getall('jy_jdpm_news',array('cid'=>$lv['cid'],'status'=>1),array('id','title'));
        }
        $return['id']=$id;
        $return['info']=$info;
		$return['list']=$list;
		exi($return);
}
if($op=='notice'){
		$cid=$_RQ['cid'] ? intval($_RQ['cid']) : 2;
		$list = pdo_getall('jy_jdpm_goods_group',array('cid' =>array(2,3)),'','','sort desc');
        $caname = pdo_getcolumn('jy_jdpm_goods_group',array('cid' =>2),'name');
        $cbname = pdo_getcolumn('jy_jdpm_goods_group',array('cid' =>3),'name');
		$where = array('status'=>1,'cid'=>$cid);
        $orderby='createtime desc';
		$pindex = max(1, intval($_RQ['page']));
		$psize = 10;
		$total='';
		$noticemap = pdo_getslice('jy_jdpm_news',$where,array($pindex,$psize),$total,'','',$orderby);
		$totalpage=ceil($total/$psize);
		$totalpage=intval($totalpage);
		$return['totalpage'] =$totalpage;
		$return['params']['page'] =$pindex;
		$return['cname'] =($cid==2)?$caname:$cbname;
		$return['noticemap'] =$noticemap;
		$return['cid'] =$cid;
		$return['caname'] =$caname;
		$return['cbname'] =$cbname;
		exi($return);
}
if($op=='details'){
        $id = intval($_RQ['id']);
        $info = pdo_get('jy_jdpm_news',array('id' =>$id));	
		$orderby='createtime desc';
		$pindex = max(1, intval($_RQ['page']));
		$psize = 10;
		$total='';
		$noticemap = pdo_getslice('jy_jdpm_news',array('status'=>1,'cid'=>$info['cid']),array($pindex,$psize),$total,'','',$orderby);
		$totalpage=ceil($total/$psize);
		$totalpage=intval($totalpage);
		$return['totalpage'] =$totalpage;
		$return['params']['page'] =$pindex;
		$return['info'] =$info;
		$return['list'] =$list;
        exi($return);
}
if($op=='footernews'){
		$post=get_postdata();
		$list = pdo_getall('jy_jdpm_goods_group',array('pid' =>12),'','','sort desc');
        foreach ($list as $lk => $lv) {
            $list[$lk]['notice'] = pdo_getall('jy_jdpm_news',array('cid'=>$lv['cid'],'status'=>1),array('id','title'));
        }
		$return['list']=$list;
		$return['pluginset']=$_SESSION['pluginset'];
		 exi($return);
}
?>